filmManage.js
var url;
function deleteFilm(){
    var selectedRows=$("#dg").datagrid("getSelections");
    if(selectedRows.length==0){
        $.messager.alert("系统提示","请选择要删除的数据！");
        return;
    }
    var strIds=[];
    for(var i=0;i<selectedRows.length;i++){
        strIds.push(selectedRows[i].id);
    }
    var ids=strIds.join(",");
    $.messager.confirm("系统提示","您确定要删除这<font color=red>"+selectedRows.length+"</font>条数据吗？",function(r){
        if(r){
            $.post("/bssp/comic/delete",{ids:ids},function(result){
                if(result.success){
                    $.messager.alert("系统提示","数据已成功删除！");
                   // windows.location
                }else{
                    $.messager.alert("系统提示",result.errorInfo);
                }
                $("#dg").datagrid("reload");
            },"json");
        }
    });
}
function refreshFilm(){
    $("#dg").datagrid("reload");
}
function openFilmAddDialog(){
    $("#dlg").dialog("open").dialog("setTitle","添加动画信息");
    url="/admin/comic/save";
}

function openFilmModifyDialog(){
    var selectedRows=$("#dg").datagrid("getSelections");
    if(selectedRows.length!=1){
        $.messager.alert("系统提示","请选择一条要编辑的数据！");
        return;
    }
    var row=selectedRows[0];
    $("#dlg").dialog("open").dialog("setTitle","编辑动画信息");
    $("#fm").form("load",row);
    url="/admin/comic/save?id="+row.id;
}

function saveFilm(){
    $("#fm").form("submit",{
        url:url,
        onSubmit:function(){
            return $(this).form("validate");
        },
        success:function(result){
            var result=eval('('+result+')');
            if(result.success){
                $.messager.alert("系统提示","保存成功！");
                resetValue();
                $("#dlg").dialog("close");
                $("#dg").datagrid("reload");
            }else{
                $.messager.alert("系统提示","保存失败！");
                return;
            }
        }
    });
}

function resetValue(){
    $("#name").val("");
    $("#url").val("");
    $("#sort").val("");
}

function closeFilmDialog(){
    $("#dlg").dialog("close");
    resetValue();
}

function formatImageName(val,row){
    return "<img width=100 height=100 src='/static/Images/Comic/"+val+"'>";
}

function formatHot(val,row){
    if(val==1){
        return "是";
    }else{
        return "不是";
    }
}


function openFilmModifyTab(){
    var selectedRows=$("#dg").datagrid("getSelections");
    if(selectedRows.length!=1){
        $.messager.alert("系统提示","请选择一个要修改的动画！");
        return;
    }
    var row=selectedRows[0];
    window.parent.openTab('修改动画','modifyComic.jsp?id='+row.id,'icon-modifyFilm');
}

function searchFilm(){
    $("#dg").datagrid('load',{
        "name":$("#s_name").val()
    });
}
